/**
 * @file gate.h
 * @brief describes a logic gate and functions for manipulating them
 * @author Scott Moyers
 * @date 2008
 */

#ifndef MY_GATE_H
#define MY_GATE_H

/**
 * @enum GateType enumeration used for gate types
 * graph algorithms
 */
enum GateType {
	AND2 = 0,
	NAND2,
	OR2,
	NOR2,
	XOR2,
	XNOR2,
	INV,
	CONST_ZERO,
	GATE_TYPES
};

/**
 * @enum Colour enumeration used for module
 * graph algorithms
 */
enum Colour {
	WHITE = 0x1,
	BLACK = 0x2
};

/** The maximum number of inputs any gate can have */
#define MAX_NUM_INPUTS 2

/**
 * @brief describes a gate
 */
struct Gate {
	enum GateType gate_type;          /**< type of the gate (AND, OR, etc.) */
	enum Colour colour;               /**< colour of the gate (for graph marking) */
	unsigned int in[MAX_NUM_INPUTS];  /**< input signal indices */
	unsigned int level;               /**< the depth this gate is in the module */
	unsigned int out;                 /**< output signal index */
	float x;                          /**< coordinates for gui layout */
	float y;                          /**< coordinates for gui layout */
};

/**
 * gets the weight of the gate
 * @param g the gate
 * @return how much the gate costs in area
 */
float get_gate_weight(struct Gate *g);

/**
 * gets the name of the gate
 * @param g the gate
 * @return const pointer to the gates name
 */
const char *get_gate_name(struct Gate *g);

/**
 * gets the number of inputs for the gate
 * @param g the gate
 * @return number of inputs for the gate
 */
unsigned int num_gate_inputs(struct Gate *g);

#endif
